//Source file: D:\\test\\com\\ce\\pms\\charge\\model\\AbstractStaVersion.java

package com.ce.pms.charge.model;

import java.math.BigDecimal;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.ce.pms.charge.service.impl.ArithmeticCharge;
import com.ce.pms.common.model.SysInfo;
import com.ce.pms.house.model.HouseDomain;
import com.sitechasia.webx.core.model.IDomainObject;

/**
 * 实体名称:收费标准版本 关联数据表:FEE_STA_VERSION
 *
 * 备注: 根据收费项目类型,派生下面几个子类.
 */
@Entity
@Table(name = "FEE_STA_VERSION")
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(
		name="CLASS_CODE",
		discriminatorType=DiscriminatorType.STRING)
public abstract class AbstractStaVersion implements IDomainObject{
	/**
	 * 主键
	 */
	@Id
	@GeneratedValue
	@Column(name = "STA_HIS_ID")
	private Long staHisId;

	/**
	 * 收费标准
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "CHARGE_STA_ID")
	private ChargeStaDomain chargeSta;

	/**
	 * 设定金额:针对计费方式是"单一计费类"的,必须设定本项,其他"阶梯计费","超额累进计费" ,"按段固定计费"则不必设定.
	 */
	@Column(name = "PRICE")
	private BigDecimal price = new BigDecimal("0.00");

	/**
	 * 版本状态:001过期;002生效
	 */
	@Column(name = "STATUZ", nullable = false, length = 3)
	private String statuz;

	/**
	 * 是否收取滞纳金: 页面如果选择设定滞纳金,设置1;否则设置0.
	 */
	@Column(name = "LATEFEE_SELECT", nullable = false, length = 1)
	private String latefeeSelect;

	/**
	 * 滞纳金计算方式
	 */
	@Column(name = "LATEFEE_MODE", length = 3)
	private String latefeeMode;

	/**
	 * 滞纳金比率
	 */
	@Column(name = "RATE")
	private BigDecimal rate = new BigDecimal("0.00");

	/**
	 * 定额滞纳金
	 */
	@Column(name = "AMT")
	private BigDecimal amt;

	/**
//	 * 收费标准类型
//	 */
//	@Column(name = "CLASS_CODE", nullable=false, length=3)
//	private String classCode;
	/**
	 * 分段参数设定集
	 *
	 * 备注:当选定计费方式"阶梯计费";"超额累进计费";"按段固定收费"时,创建本项.
	 */
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy="staHis")
	private Set<SectSta> secStas;

	@Embedded
	private SysInfo sysInfo;

	/**
	 * @roseuid 48757D0F01C5
	 */
	public AbstractStaVersion() {

	}
	/**
	 * mini constructor
	 * @param latefeeSelect 是否收取滞纳金: 页面如果选择设定滞纳金,设置1;否则设置0.
	 * @param sysInfo       系统信息
	 */
	public AbstractStaVersion(String latefeeSelect,  SysInfo sysInfo) {
		super();
		this.latefeeSelect = latefeeSelect;
		this.sysInfo = sysInfo;
	}

	/**
	 * 功能描述:根据计算量及计算规则返回计算结果<br>
	 * @param amount 计算量
	 * @return<br>
	 * Create author:罗军林<br>
	 * Create on:2008-8-18<br>
	 * Edit author:<br>
	 * Edit on:<br>
	 * Why:<br>
	 */
	public BigDecimal calculate(BigDecimal amount){
		ArithmeticCharge arithmeticCharge=new ArithmeticCharge(this);
		return arithmeticCharge.calculate(amount);
	}

	public BigDecimal getAmt() {
		return amt;
	}
	public void setAmt(BigDecimal amt) {
		this.amt = amt;
	}
	public ChargeStaDomain getChargeSta() {
		return chargeSta;
	}
	public void setChargeSta(ChargeStaDomain chargeSta) {
		this.chargeSta = chargeSta;
	}

	public String getLatefeeMode() {
		return latefeeMode;
	}
	public void setLatefeeMode(String latefeeMode) {
		this.latefeeMode = latefeeMode;
	}
	public String getLatefeeSelect() {
		return latefeeSelect;
	}
	public void setLatefeeSelect(String latefeeSelect) {
		this.latefeeSelect = latefeeSelect;
	}
	public BigDecimal getPrice() {
		return price;
	}
	public void setPrice(BigDecimal price) {
		this.price = price;
	}
	public BigDecimal getRate() {
		return rate;
	}
	public void setRate(BigDecimal rate) {
		this.rate = rate;
	}
	public Set<SectSta> getSecStas() {
		return secStas;
	}
	public void setSecStas(Set<SectSta> secStas) {
		this.secStas = secStas;
	}
	public Long getStaHisId() {
		return staHisId;
	}
	public void setStaHisId(Long staHisId) {
		this.staHisId = staHisId;
	}
	public String getStatuz() {
		return statuz;
	}
	public void setStatuz(String statuz) {
		this.statuz = statuz;
	}
	public SysInfo getSysInfo() {
		return sysInfo;
	}
	public void setSysInfo(SysInfo sysInfo) {
		this.sysInfo = sysInfo;
	}


}
